﻿using System;
using System.Collections.Generic;
using System.Globalization;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Data;

namespace PlaceOrder_Client.Converters
{
    public class PositiveNegativeToColorConverter : IValueConverter
    {
        public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
        {

            if (value is decimal decimalValue)
            {
                if(decimalValue > 0)
                {
                    return "Green";
                }else if(decimalValue<0)
                {
                    return "Red";
                }
                //return decimalValue > 0 ? "Green" : "Red";
            }
            return "Black"; // 默认颜色，如果转换失败
            //if (valueStr is string strValue && double.TryParse(valueStr, out double doubleValue))
            //{
            //    return doubleValue >= 0 ? "Green" : "Red";
            //}
            //return "Black"; // Default color if conversion fails
        }

        public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
        {
            return null;
        }
    }
}
